﻿activityFeed.CommentViewModel = function (currenctUser, removeCommentHandler) {
    var self = this;

    this.id = ko.observable();
    this.text = ko.observable();
    this.publisher = ko.observable();
    this.publishedOn = ko.observable(new Date());

    this.isAllowed = ko.computed(function () { return !!currenctUser && !!self.publisher() && self.publisher().id == currenctUser.id; });

    this.isEditable = ko.computed(function () { return !!self.id() && self.isAllowed(); });
    

    this.removeComment = ko.asyncCommand(
        function () {
            return removeCommentHandler(self);
        }, self.isEditable, self.isAllowed);
};